From 92639e1357cbd76f9345169841856f518afe5281 Mon Sep 17 00:00:00 2001 From: "bren@anvil.research" Date: Thu, 18 Nov 2004 14:58:31 +0000 Subject: [PATCH] bitkeeper revision 1.1159.170.45 (419cb897jRheBdVSsNm7oNbz_Q4DeQ) Bring x2d2 to latest headers. Quite some fixes to make it compile. --- .rootkeys | 3 +- tools/x2d2/Makefile | 24 +- tools/x2d2/cntrl_con.c | 7 +- tools/x2d2/domain_controller.h | 562 ------------------------------ tools/x2d2/{main.c => minixend.c} | 120 ++----- tools/x2d2/minixend.h | 64 ---- 6 files changed, 44 insertions(+), 736 deletions(-) delete mode 100644 tools/x2d2/domain_controller.h rename tools/x2d2/{main.c => minixend.c} (89%) diff --git a/.rootkeys b/.rootkeys index 3f63948f7a..7f9a7fb994 100644 --- a/.rootkeys +++ b/.rootkeys @@ -531,8 +531,7 @@ 40fcefb3zGC9XNBkSwTEobCoq8YClA tools/sv/inc/style.css 4194e861IgTabTt8HOuh143QIJFD1Q tools/x2d2/Makefile 4194e861M2gcBz4i94cQYpqzi8n6UA tools/x2d2/cntrl_con.c -4194e861xToz-o2KH6VT_CPJqVGMCg tools/x2d2/domain_controller.h -4194e8612TrrMvC8ZlA4h2ZYCPWz4g tools/x2d2/main.c +4194e8612TrrMvC8ZlA4h2ZYCPWz4g tools/x2d2/minixend.c 4194e861x2eqNCD61RYPCUEBVdMYuw tools/x2d2/minixend.h 4194e861A4V9VbD_FYmgXpYEj5YwVg tools/x2d2/util.c 403a3edbrr8RE34gkbR40zep98SXbg tools/xentrace/Makefile diff --git a/tools/x2d2/Makefile b/tools/x2d2/Makefile index e1337bffa5..36de2856ae 100644 --- a/tools/x2d2/Makefile +++ b/tools/x2d2/Makefile @@ -1,10 +1,22 @@ -CFLAGS+=-Wall -g -Werror +XEN_ROOT=../.. +include $(XEN_ROOT)/tools/Make.defs -SRCS=main.c cntrl_con.c util.c +CC = gcc +CFLAGS = -Wall -Werror -g -all: minixend +CFLAGS += -I $(XEN_XC) +CFLAGS += -I $(XEN_LIBXC) +CFLAGS += -I $(XEN_LIBXUTIL) -#$(SRCS): minixend.h +HDRS = $(wildcard *.h) +OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) -minixend: $(subst .c,.o,$(SRCS)) - gcc $^ -o $@ $(LDFLAGS) -lxc -lpthread +BIN = minixend + +all: $(BIN) + +clean: + $(RM) *.a *.so *.o *.rpm $(BIN) + +$(BIN): $(OBJS) + $(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_LIBXUTIL) -lxc -lxutil -lpthread diff --git a/tools/x2d2/cntrl_con.c b/tools/x2d2/cntrl_con.c index 5851d7df38..46084dbdee 100644 --- a/tools/x2d2/cntrl_con.c +++ b/tools/x2d2/cntrl_con.c @@ -40,7 +40,6 @@ domain_created(const char *name, int mem_kb, int domid) pthread_mutex_init(&d->mux, NULL); pthread_cond_init(&d->cond, NULL); - pthread_create(&d->thread, NULL, domain_thread_func, d); list_insert_after(&d->domain_list, &head_domain); @@ -164,7 +163,7 @@ create_command_handler(struct open_connection *oc, const struct command *ign, send_message(oc, "E01 failed to parse %s\n", args); return; } - r = xc_domain_create(xc_handle, mem_kb, name, -1, 0, &domid); + r = xc_domain_create(xc_handle, mem_kb, -1, 0, &domid); if (r < 0) { send_message(oc, "E02 creating domain (%s)\n", strerror(errno)); @@ -377,8 +376,8 @@ destroy_command_handler(struct open_connection *oc, r = xc_domain_destroy(xc_handle, domid); if (r < 0) { - send_message(oc, "E19 error destroying domain %d: %s\n", - domid, sys_errlist[errno]); + send_message( oc, "E19 error destroying domain %d: %s\n", + domid, strerror(errno) ); return; } d->state = DOM_STATE_DEAD; diff --git a/tools/x2d2/domain_controller.h b/tools/x2d2/domain_controller.h deleted file mode 100644 index 14775c07c1..0000000000 --- a/tools/x2d2/domain_controller.h +++ /dev/null @@ -1,562 +0,0 @@ -/****************************************************************************** - * domain_controller.h - * - * Interface to server controller (e.g., 'xend'). This header file defines the - * interface that is shared with guest OSes. - * - * Copyright (c) 2004, K A Fraser - */ - -/* I've copied this from the xen source pool as getting Xen and - userspace headers to play nicely together is beyond me -- sos22 */ -#define PACKED __attribute__ ((packed)) -typedef unsigned long memory_t; /* Full-sized pointer/address/memory-size. */ -#define __MEMORY_PADDING(_X) u32 __pad_ ## _X -#define _MEMORY_PADDING(_X) __MEMORY_PADDING(_X) -#define MEMORY_PADDING _MEMORY_PADDING(__LINE__) -typedef u16 domid_t; - -/* - * Reason codes for SCHEDOP_shutdown. These are opaque to Xen but may be - * interpreted by control software to determine the appropriate action. These - * are only really advisories: the controller can actually do as it likes. - */ -#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */ -#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */ -#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */ - - -/* - * CONTROLLER MESSAGING INTERFACE. - */ - -typedef struct { - u8 type; /* 0: echoed in response */ - u8 subtype; /* 1: echoed in response */ - u8 id; /* 2: echoed in response */ - u8 length; /* 3: number of bytes in 'msg' */ - u8 msg[60]; /* 4: type-specific message data */ -} PACKED control_msg_t; /* 64 bytes */ - -#define CONTROL_RING_SIZE 8 -typedef u32 CONTROL_RING_IDX; -#define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1)) - -typedef struct { - control_msg_t tx_ring[CONTROL_RING_SIZE]; /* 0: guest -> controller */ - control_msg_t rx_ring[CONTROL_RING_SIZE]; /* 512: controller -> guest */ - CONTROL_RING_IDX tx_req_prod, tx_resp_prod; /* 1024, 1028 */ - CONTROL_RING_IDX rx_req_prod, rx_resp_prod; /* 1032, 1036 */ -} PACKED control_if_t; /* 1040 bytes */ - -/* - * Top-level command types. - */ -#define CMSG_CONSOLE 0 /* Console */ -#define CMSG_BLKIF_BE 1 /* Block-device backend */ -#define CMSG_BLKIF_FE 2 /* Block-device frontend */ -#define CMSG_NETIF_BE 3 /* Network-device backend */ -#define CMSG_NETIF_FE 4 /* Network-device frontend */ -#define CMSG_SHUTDOWN 6 /* Shutdown messages */ -#define CMSG_PDB_BE 7 /* PDB backend. */ -#define CMSG_PDB_FE 8 /* PDB frontend. */ - -/****************************************************************************** - * CONSOLE DEFINITIONS - */ - -/* - * Subtypes for console messages. - */ -#define CMSG_CONSOLE_DATA 0 - - -/****************************************************************************** - * BLOCK-INTERFACE FRONTEND DEFINITIONS - */ - -/* Messages from domain controller to guest. */ -#define CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED 0 - -/* Messages from guest to domain controller. */ -#define CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED 32 -#define CMSG_BLKIF_FE_INTERFACE_CONNECT 33 -#define CMSG_BLKIF_FE_INTERFACE_DISCONNECT 34 - -/* These are used by both front-end and back-end drivers. */ -#define blkif_vdev_t u16 -#define blkif_pdev_t u16 -#define blkif_sector_t u64 - -/* - * CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED: - * Notify a guest about a status change on one of its block interfaces. - * If the interface is DESTROYED or DOWN then the interface is disconnected: - * 1. The shared-memory frame is available for reuse. - * 2. Any unacknowledged messgaes pending on the interface were dropped. - */ -#define BLKIF_INTERFACE_STATUS_DESTROYED 0 /* Interface doesn't exist. */ -#define BLKIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */ -#define BLKIF_INTERFACE_STATUS_CONNECTED 2 /* Exists and is connected. */ -typedef struct { - u32 handle; /* 0 */ - u32 status; /* 4 */ - u16 evtchn; /* 8: (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */ -} PACKED blkif_fe_interface_status_changed_t; /* 10 bytes */ - -/* - * CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED: - * Notify the domain controller that the front-end driver is DOWN or UP. - * When the driver goes DOWN then the controller will send no more - * status-change notifications. When the driver comes UP then the controller - * will send a notification for each interface that currently exists. - * If the driver goes DOWN while interfaces are still UP, the domain - * will automatically take the interfaces DOWN. - */ -#define BLKIF_DRIVER_STATUS_DOWN 0 -#define BLKIF_DRIVER_STATUS_UP 1 -typedef struct { - /* IN */ - u32 status; /* 0: BLKIF_DRIVER_STATUS_??? */ - /* OUT */ - /* - * Tells driver how many interfaces it should expect to immediately - * receive notifications about. - */ - u32 nr_interfaces; /* 4 */ -} PACKED blkif_fe_driver_status_changed_t; /* 8 bytes */ - -/* - * CMSG_BLKIF_FE_INTERFACE_CONNECT: - * If successful, the domain controller will acknowledge with a - * STATUS_CONNECTED message. - */ -typedef struct { - u32 handle; /* 0 */ - u32 __pad; - memory_t shmem_frame; /* 8 */ - MEMORY_PADDING; -} PACKED blkif_fe_interface_connect_t; /* 16 bytes */ - -/* - * CMSG_BLKIF_FE_INTERFACE_DISCONNECT: - * If successful, the domain controller will acknowledge with a - * STATUS_DISCONNECTED message. - */ -typedef struct { - u32 handle; /* 0 */ -} PACKED blkif_fe_interface_disconnect_t; /* 4 bytes */ - - -/****************************************************************************** - * BLOCK-INTERFACE BACKEND DEFINITIONS - */ - -/* Messages from domain controller. */ -#define CMSG_BLKIF_BE_CREATE 0 /* Create a new block-device interface. */ -#define CMSG_BLKIF_BE_DESTROY 1 /* Destroy a block-device interface. */ -#define CMSG_BLKIF_BE_CONNECT 2 /* Connect i/f to remote driver. */ -#define CMSG_BLKIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */ -#define CMSG_BLKIF_BE_VBD_CREATE 4 /* Create a new VBD for an interface. */ -#define CMSG_BLKIF_BE_VBD_DESTROY 5 /* Delete a VBD from an interface. */ -#define CMSG_BLKIF_BE_VBD_GROW 6 /* Append an extent to a given VBD. */ -#define CMSG_BLKIF_BE_VBD_SHRINK 7 /* Remove last extent from a given VBD. */ - -/* Messages to domain controller. */ -#define CMSG_BLKIF_BE_DRIVER_STATUS_CHANGED 32 - -/* - * Message request/response definitions for block-device messages. - */ - -typedef struct { - blkif_sector_t sector_start; /* 0 */ - blkif_sector_t sector_length; /* 8 */ - blkif_pdev_t device; /* 16 */ - u16 __pad; /* 18 */ -} PACKED blkif_extent_t; /* 20 bytes */ - -/* Non-specific 'okay' return. */ -#define BLKIF_BE_STATUS_OKAY 0 -/* Non-specific 'error' return. */ -#define BLKIF_BE_STATUS_ERROR 1 -/* The following are specific error returns. */ -#define BLKIF_BE_STATUS_INTERFACE_EXISTS 2 -#define BLKIF_BE_STATUS_INTERFACE_NOT_FOUND 3 -#define BLKIF_BE_STATUS_INTERFACE_CONNECTED 4 -#define BLKIF_BE_STATUS_VBD_EXISTS 5 -#define BLKIF_BE_STATUS_VBD_NOT_FOUND 6 -#define BLKIF_BE_STATUS_OUT_OF_MEMORY 7 -#define BLKIF_BE_STATUS_EXTENT_NOT_FOUND 8 -#define BLKIF_BE_STATUS_MAPPING_ERROR 9 - -/* This macro can be used to create an array of descriptive error strings. */ -#define BLKIF_BE_STATUS_ERRORS { \ - "Okay", \ - "Non-specific error", \ - "Interface already exists", \ - "Interface not found", \ - "Interface is still connected", \ - "VBD already exists", \ - "VBD not found", \ - "Out of memory", \ - "Extent not found for VBD", \ - "Could not map domain memory" } - -/* - * CMSG_BLKIF_BE_CREATE: - * When the driver sends a successful response then the interface is fully - * created. The controller will send a DOWN notification to the front-end - * driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Domain attached to new interface. */ - u16 __pad; - u32 blkif_handle; /* 4: Domain-specific interface handle. */ - /* OUT */ - u32 status; /* 8 */ -} PACKED blkif_be_create_t; /* 12 bytes */ - -/* - * CMSG_BLKIF_BE_DESTROY: - * When the driver sends a successful response then the interface is fully - * torn down. The controller will send a DESTROYED notification to the - * front-end driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Identify interface to be destroyed. */ - u16 __pad; - u32 blkif_handle; /* 4: ...ditto... */ - /* OUT */ - u32 status; /* 8 */ -} PACKED blkif_be_destroy_t; /* 12 bytes */ - -/* - * CMSG_BLKIF_BE_CONNECT: - * When the driver sends a successful response then the interface is fully - * connected. The controller will send a CONNECTED notification to the - * front-end driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Domain attached to new interface. */ - u16 __pad; - u32 blkif_handle; /* 4: Domain-specific interface handle. */ - memory_t shmem_frame; /* 8: Page cont. shared comms window. */ - MEMORY_PADDING; - u32 evtchn; /* 16: Event channel for notifications. */ - /* OUT */ - u32 status; /* 20 */ -} PACKED blkif_be_connect_t; /* 24 bytes */ - -/* - * CMSG_BLKIF_BE_DISCONNECT: - * When the driver sends a successful response then the interface is fully - * disconnected. The controller will send a DOWN notification to the front-end - * driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Domain attached to new interface. */ - u16 __pad; - u32 blkif_handle; /* 4: Domain-specific interface handle. */ - /* OUT */ - u32 status; /* 8 */ -} PACKED blkif_be_disconnect_t; /* 12 bytes */ - -/* CMSG_BLKIF_BE_VBD_CREATE */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Identify blkdev interface. */ - u16 __pad; - u32 blkif_handle; /* 4: ...ditto... */ - blkif_vdev_t vdevice; /* 8: Interface-specific id for this VBD. */ - u16 readonly; /* 10: Non-zero -> VBD isn't writable. */ - /* OUT */ - u32 status; /* 12 */ -} PACKED blkif_be_vbd_create_t; /* 16 bytes */ - -/* CMSG_BLKIF_BE_VBD_DESTROY */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Identify blkdev interface. */ - u16 __pad0; /* 2 */ - u32 blkif_handle; /* 4: ...ditto... */ - blkif_vdev_t vdevice; /* 8: Interface-specific id of the VBD. */ - u16 __pad1; /* 10 */ - /* OUT */ - u32 status; /* 12 */ -} PACKED blkif_be_vbd_destroy_t; /* 16 bytes */ - -/* CMSG_BLKIF_BE_VBD_GROW */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Identify blkdev interface. */ - u16 __pad0; /* 2 */ - u32 blkif_handle; /* 4: ...ditto... */ - blkif_extent_t extent; /* 8: Physical extent to append to VBD. */ - blkif_vdev_t vdevice; /* 28: Interface-specific id of the VBD. */ - u16 __pad1; /* 30 */ - /* OUT */ - u32 status; /* 32 */ -} PACKED blkif_be_vbd_grow_t; /* 36 bytes */ - -/* CMSG_BLKIF_BE_VBD_SHRINK */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Identify blkdev interface. */ - u16 __pad0; /* 2 */ - u32 blkif_handle; /* 4: ...ditto... */ - blkif_vdev_t vdevice; /* 8: Interface-specific id of the VBD. */ - u16 __pad1; /* 10 */ - /* OUT */ - u32 status; /* 12 */ -} PACKED blkif_be_vbd_shrink_t; /* 16 bytes */ - -/* - * CMSG_BLKIF_BE_DRIVER_STATUS_CHANGED: - * Notify the domain controller that the back-end driver is DOWN or UP. - * If the driver goes DOWN while interfaces are still UP, the controller - * will automatically send DOWN notifications. - */ -typedef struct { - u32 status; /* 0: BLKIF_DRIVER_STATUS_??? */ -} PACKED blkif_be_driver_status_changed_t; /* 4 bytes */ - - -/****************************************************************************** - * NETWORK-INTERFACE FRONTEND DEFINITIONS - */ - -/* Messages from domain controller to guest. */ -#define CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED 0 - -/* Messages from guest to domain controller. */ -#define CMSG_NETIF_FE_DRIVER_STATUS_CHANGED 32 -#define CMSG_NETIF_FE_INTERFACE_CONNECT 33 -#define CMSG_NETIF_FE_INTERFACE_DISCONNECT 34 - -/* - * CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED: - * Notify a guest about a status change on one of its network interfaces. - * If the interface is DESTROYED or DOWN then the interface is disconnected: - * 1. The shared-memory frame is available for reuse. - * 2. Any unacknowledged messgaes pending on the interface were dropped. - */ -#define NETIF_INTERFACE_STATUS_DESTROYED 0 /* Interface doesn't exist. */ -#define NETIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */ -#define NETIF_INTERFACE_STATUS_CONNECTED 2 /* Exists and is connected. */ -typedef struct { - u32 handle; /* 0 */ - u32 status; /* 4 */ - u16 evtchn; /* 8: status == NETIF_INTERFACE_STATUS_CONNECTED */ - u8 mac[6]; /* 10: status == NETIF_INTERFACE_STATUS_CONNECTED */ -} PACKED netif_fe_interface_status_changed_t; /* 16 bytes */ - -/* - * CMSG_NETIF_FE_DRIVER_STATUS_CHANGED: - * Notify the domain controller that the front-end driver is DOWN or UP. - * When the driver goes DOWN then the controller will send no more - * status-change notifications. When the driver comes UP then the controller - * will send a notification for each interface that currently exists. - * If the driver goes DOWN while interfaces are still UP, the domain - * will automatically take the interfaces DOWN. - */ -#define NETIF_DRIVER_STATUS_DOWN 0 -#define NETIF_DRIVER_STATUS_UP 1 -typedef struct { - /* IN */ - u32 status; /* 0: NETIF_DRIVER_STATUS_??? */ - /* OUT */ - /* - * Tells driver how many interfaces it should expect to immediately - * receive notifications about. - */ - u32 nr_interfaces; /* 4 */ -} PACKED netif_fe_driver_status_changed_t; /* 8 bytes */ - -/* - * CMSG_NETIF_FE_INTERFACE_CONNECT: - * If successful, the domain controller will acknowledge with a - * STATUS_CONNECTED message. - */ -typedef struct { - u32 handle; /* 0 */ - u32 __pad; /* 4 */ - memory_t tx_shmem_frame; /* 8 */ - MEMORY_PADDING; - memory_t rx_shmem_frame; /* 16 */ - MEMORY_PADDING; -} PACKED netif_fe_interface_connect_t; /* 24 bytes */ - -/* - * CMSG_NETIF_FE_INTERFACE_DISCONNECT: - * If successful, the domain controller will acknowledge with a - * STATUS_DISCONNECTED message. - */ -typedef struct { - u32 handle; /* 0 */ -} PACKED netif_fe_interface_disconnect_t; /* 4 bytes */ - - -/****************************************************************************** - * NETWORK-INTERFACE BACKEND DEFINITIONS - */ - -/* Messages from domain controller. */ -#define CMSG_NETIF_BE_CREATE 0 /* Create a new net-device interface. */ -#define CMSG_NETIF_BE_DESTROY 1 /* Destroy a net-device interface. */ -#define CMSG_NETIF_BE_CONNECT 2 /* Connect i/f to remote driver. */ -#define CMSG_NETIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */ - -/* Messages to domain controller. */ -#define CMSG_NETIF_BE_DRIVER_STATUS_CHANGED 32 - -/* - * Message request/response definitions for net-device messages. - */ - -/* Non-specific 'okay' return. */ -#define NETIF_BE_STATUS_OKAY 0 -/* Non-specific 'error' return. */ -#define NETIF_BE_STATUS_ERROR 1 -/* The following are specific error returns. */ -#define NETIF_BE_STATUS_INTERFACE_EXISTS 2 -#define NETIF_BE_STATUS_INTERFACE_NOT_FOUND 3 -#define NETIF_BE_STATUS_INTERFACE_CONNECTED 4 -#define NETIF_BE_STATUS_OUT_OF_MEMORY 5 -#define NETIF_BE_STATUS_MAPPING_ERROR 6 - -/* This macro can be used to create an array of descriptive error strings. */ -#define NETIF_BE_STATUS_ERRORS { \ - "Okay", \ - "Non-specific error", \ - "Interface already exists", \ - "Interface not found", \ - "Interface is still connected", \ - "Out of memory", \ - "Could not map domain memory" } - -/* - * CMSG_NETIF_BE_CREATE: - * When the driver sends a successful response then the interface is fully - * created. The controller will send a DOWN notification to the front-end - * driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Domain attached to new interface. */ - u16 __pad0; /* 2 */ - u32 netif_handle; /* 4: Domain-specific interface handle. */ - u8 mac[6]; /* 8 */ - u16 __pad1; /* 14 */ - /* OUT */ - u32 status; /* 16 */ -} PACKED netif_be_create_t; /* 20 bytes */ - -/* - * CMSG_NETIF_BE_DESTROY: - * When the driver sends a successful response then the interface is fully - * torn down. The controller will send a DESTROYED notification to the - * front-end driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Identify interface to be destroyed. */ - u16 __pad; - u32 netif_handle; /* 4: ...ditto... */ - /* OUT */ - u32 status; /* 8 */ -} PACKED netif_be_destroy_t; /* 12 bytes */ - -/* - * CMSG_NETIF_BE_CONNECT: - * When the driver sends a successful response then the interface is fully - * connected. The controller will send a CONNECTED notification to the - * front-end driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Domain attached to new interface. */ - u16 __pad0; /* 2 */ - u32 netif_handle; /* 4: Domain-specific interface handle. */ - memory_t tx_shmem_frame; /* 8: Page cont. tx shared comms window. */ - MEMORY_PADDING; - memory_t rx_shmem_frame; /* 16: Page cont. rx shared comms window. */ - MEMORY_PADDING; - u16 evtchn; /* 24: Event channel for notifications. */ - u16 __pad1; /* 26 */ - /* OUT */ - u32 status; /* 28 */ -} PACKED netif_be_connect_t; /* 32 bytes */ - -/* - * CMSG_NETIF_BE_DISCONNECT: - * When the driver sends a successful response then the interface is fully - * disconnected. The controller will send a DOWN notification to the front-end - * driver. - */ -typedef struct { - /* IN */ - domid_t domid; /* 0: Domain attached to new interface. */ - u16 __pad; - u32 netif_handle; /* 4: Domain-specific interface handle. */ - /* OUT */ - u32 status; /* 8 */ -} PACKED netif_be_disconnect_t; /* 12 bytes */ - -/* - * CMSG_NETIF_BE_DRIVER_STATUS_CHANGED: - * Notify the domain controller that the back-end driver is DOWN or UP. - * If the driver goes DOWN while interfaces are still UP, the domain - * will automatically send DOWN notifications. - */ -typedef struct { - u32 status; /* 0: NETIF_DRIVER_STATUS_??? */ -} PACKED netif_be_driver_status_changed_t; /* 4 bytes */ - - -/****************************************************************************** - * SHUTDOWN DEFINITIONS - */ - -/* - * Subtypes for shutdown messages. - */ -#define CMSG_SHUTDOWN_POWEROFF 0 /* Clean shutdown (SHUTDOWN_poweroff). */ -#define CMSG_SHUTDOWN_REBOOT 1 /* Clean shutdown (SHUTDOWN_reboot). */ -#define CMSG_SHUTDOWN_SUSPEND 2 /* Create suspend info, then */ - /* SHUTDOWN_suspend. */ - -/****************************************************************************** - * PDB DEFINITIONS - */ - -/* Notify the backend that a new frontend has connected. */ -#define CMSG_PDB_BE_INTERFACE_CONNECTED 0 -typedef struct { - int assist_port; - int event_port; -} pdb_be_connected_t; - -/* Notify the domain controller that the status of the backend has - changed. */ -#define CMSG_PDB_BE_DRIVER_STATUS_CHANGED 1 -typedef struct { - unsigned status; -#define PDB_DRIVER_STATUS_UP 1 - unsigned long event_page; - unsigned long assist_page; -} pdb_be_driver_status_changed_t; - -/* Notify a front end that a back end just popped up. */ -#define CMSG_PDB_FE_NEW_BE 0 -typedef struct { - int domain; - int assist_evtchn; - int event_evtchn; - unsigned long assist_frame; - unsigned long event_frame; -} pdb_fe_new_be_t; diff --git a/tools/x2d2/main.c b/tools/x2d2/minixend.c similarity index 89% rename from tools/x2d2/main.c rename to tools/x2d2/minixend.c index c8de6b6b52..64fe27195a 100644 --- a/tools/x2d2/main.c +++ b/tools/x2d2/minixend.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -48,14 +49,10 @@ head_console = LIST_HEAD(&head_console); foreach_item(d, &head_connection, struct open_connection, connection_list) /* Not modified after initial start up */ -static struct domain * -dom0; -unsigned -xc_handle; -static int -listen_fd; -int -evtchn_fd; +static struct domain *dom0; +unsigned xc_handle; +static int listen_fd; +int evtchn_fd; static struct list_head head_event_receiver = LIST_HEAD(&head_event_receiver); @@ -332,11 +329,11 @@ send_control_message(int type, int subtype, int id, -- Front end sends us a NETIF_FE_INTERFACE_CONNECT for each netif */ static void -handle_netif_fe_driver_status_changed(control_msg_t *m, - netif_fe_driver_status_changed_t *sh, - struct domain *d) +handle_netif_fe_driver_status(control_msg_t *m, + netif_fe_driver_status_t *sh, + struct domain *d) { - netif_fe_interface_status_changed_t if_s; + netif_fe_interface_status_t if_s; control_msg_t be_msg; netif_be_create_t *be = (void *)be_msg.msg; int r; @@ -346,11 +343,9 @@ handle_netif_fe_driver_status_changed(control_msg_t *m, /* Tell the back end about the new interface coming * up. */ if (d->created_netif_backend) { - PRINTF(10, "Front end came up twice in dom %d -> reporting no interfaces this time around.\n", d->domid); - sh->nr_interfaces = 0; send_control_reply(m, d); send_control_message(CMSG_NETIF_FE, - CMSG_NETIF_FE_DRIVER_STATUS_CHANGED, + CMSG_NETIF_FE_DRIVER_STATUS, 1, sizeof(*sh), sh, @@ -374,10 +369,9 @@ handle_netif_fe_driver_status_changed(control_msg_t *m, if (be->status != NETIF_BE_STATUS_OKAY) { /* Uh oh... can't bring back end * up. */ - sh->nr_interfaces = 0; send_control_reply(m, d); send_control_message(CMSG_NETIF_FE, - CMSG_NETIF_FE_DRIVER_STATUS_CHANGED, + CMSG_NETIF_FE_DRIVER_STATUS, 1, sizeof(*sh), sh, @@ -400,10 +394,9 @@ handle_netif_fe_driver_status_changed(control_msg_t *m, /* Tell domain how many interfaces it has to deal * with. */ - sh->nr_interfaces = 1; send_control_reply(m, d); send_control_message(CMSG_NETIF_FE, - CMSG_NETIF_FE_DRIVER_STATUS_CHANGED, + CMSG_NETIF_FE_DRIVER_STATUS, 1, sizeof(*sh), sh, @@ -413,7 +406,7 @@ handle_netif_fe_driver_status_changed(control_msg_t *m, if_s.handle = 0; if_s.status = NETIF_INTERFACE_STATUS_DISCONNECTED; send_control_message(CMSG_NETIF_FE, - CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, + CMSG_NETIF_FE_INTERFACE_STATUS, 1, sizeof(if_s), &if_s, @@ -434,7 +427,7 @@ handle_netif_fe_interface_connect(control_msg_t *m, { control_msg_t be_msg; netif_be_connect_t *bmsg = (void *)be_msg.msg; - netif_fe_interface_status_changed_t fmsg = {0}; + netif_fe_interface_status_t fmsg = {0}; int evtchn_ports[2]; int r; @@ -477,7 +470,7 @@ handle_netif_fe_interface_connect(control_msg_t *m, memcpy(fmsg.mac, d->netif_mac, 6); send_control_message(CMSG_NETIF_FE, - CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, + CMSG_NETIF_FE_INTERFACE_STATUS, 0, sizeof(fmsg), &fmsg, @@ -489,11 +482,11 @@ static void process_netif_fe_message(control_msg_t *m, struct domain *d) { switch (m->subtype) { - case CMSG_NETIF_FE_DRIVER_STATUS_CHANGED: + case CMSG_NETIF_FE_DRIVER_STATUS: { - netif_fe_driver_status_changed_t *sh = - (netif_fe_driver_status_changed_t *)m->msg; - handle_netif_fe_driver_status_changed(m, sh, d); + netif_fe_driver_status_t *sh = + (netif_fe_driver_status_t *)m->msg; + handle_netif_fe_driver_status(m, sh, d); break; } case CMSG_NETIF_FE_INTERFACE_CONNECT: @@ -509,72 +502,6 @@ process_netif_fe_message(control_msg_t *m, struct domain *d) } } -static void -process_pdb_be_driver_status_changed_message(control_msg_t *msg, - pdb_be_driver_status_changed_t*pe, - struct domain *d) -{ - pdb_be_connected_t conn; - pdb_fe_new_be_t new_be; - int assist_channel[2]; - int event_channel[2]; - int r; - - switch (pe->status) { - case PDB_DRIVER_STATUS_UP: - PRINTF(4, "creating event channel for PDB device\n"); - r = allocate_event_channel(d, assist_channel); - r |= allocate_event_channel(d, event_channel); - if (r < 0) - abort(); /* XXX need to handle this */ - - send_trivial_control_reply(msg, d); - - PRINTF(4, "informing front end of event channel\n"); - conn.assist_port = assist_channel[1]; - conn.event_port = event_channel[1]; - send_control_message(CMSG_PDB_BE, - CMSG_PDB_BE_INTERFACE_CONNECTED, - 0, - sizeof(conn), - &conn, - d); - - PRINTF(4, "informing back end of front end\n"); - new_be.domain = d->domid; - new_be.assist_evtchn = assist_channel[0]; - new_be.event_evtchn = event_channel[0]; - new_be.assist_frame = pe->assist_page; - new_be.event_frame = pe->event_page; - send_control_message(CMSG_PDB_FE, - CMSG_PDB_FE_NEW_BE, - 0, - sizeof(new_be), - &new_be, - dom0); - break; - default: - warnx("unknown pdb status %d", pe->status); - } -} - -static void -process_pdb_be_message(control_msg_t *msg, struct domain *d) -{ - switch (msg->subtype) { - case CMSG_PDB_BE_DRIVER_STATUS_CHANGED: - { - pdb_be_driver_status_changed_t *pe = - (pdb_be_driver_status_changed_t *)msg->msg; - process_pdb_be_driver_status_changed_message(msg, pe, d); - break; - } - default: - warnx("unknown pdb back end message subtype %d", - msg->subtype); - } -} - static void process_control_message(control_msg_t *msg, struct domain *d) { @@ -593,9 +520,6 @@ process_control_message(control_msg_t *msg, struct domain *d) case CMSG_NETIF_FE: process_netif_fe_message(&m, d); break; - case CMSG_PDB_BE: - process_pdb_be_message(&m, d); - break; default: warnx("unknown control message type %d", m.type); } @@ -685,7 +609,7 @@ signal_domain(struct domain *d) PRINTF(1, "delivering event id %d\n", evt->id); pthread_cond_broadcast(&evt->cond); pthread_mutex_unlock(&d->mux); - pthread_yield(); + sched_yield(); pthread_mutex_lock(&d->mux); } else { warnx("unexpected message id %d discarded", @@ -701,7 +625,7 @@ signal_domain(struct domain *d) PRINTF(1, "delivering event rep id %d\n", evt->id); pthread_cond_broadcast(&evt->cond); pthread_mutex_unlock(&d->mux); - pthread_yield(); + sched_yield(); pthread_mutex_lock(&d->mux); } else { warnx("unexpected message reply id %d discarded", @@ -949,7 +873,7 @@ find_dom0(void) err(1, "binding to domain 0 control event channel"); work->domid = 0; - work->name = xstrdup("dom0"); + work->name = strdup("dom0"); work->mem_kb = info.max_memkb; work->state = DOM_STATE_RUNNING; work->shared_info_mfn = info.shared_info_frame; diff --git a/tools/x2d2/minixend.h b/tools/x2d2/minixend.h index 1dc4cee9f4..db28d48529 100644 --- a/tools/x2d2/minixend.h +++ b/tools/x2d2/minixend.h @@ -3,70 +3,6 @@ #include #include -#include "domain_controller.h" - -/* Yet again, persuading Xen headers to include successfully in a - userspace process proves to be beyond me. Sigh. */ -#define MAX_VIRT_CPUS 1 - -typedef struct { - u32 tsc_bits; /* 0: 32 bits read from the CPU's TSC. */ - u32 tsc_bitshift; /* 4: 'tsc_bits' uses N:N+31 of TSC. */ -} PACKED tsc_timestamp_t; /* 8 bytes */ - -typedef struct { - u64 mfn_to_pfn_start; /* MFN of start of m2p table */ - u64 pfn_to_mfn_frame_list; /* MFN of a table of MFNs that - make up p2m table */ -} PACKED arch_shared_info_t; - -typedef struct -{ - unsigned long ebx; - unsigned long ecx; - unsigned long edx; - unsigned long esi; - unsigned long edi; - unsigned long ebp; - unsigned long eax; - unsigned long ds; - unsigned long es; - unsigned long fs; - unsigned long gs; - unsigned long _unused; - unsigned long eip; - unsigned long cs; - unsigned long eflags; - unsigned long esp; - unsigned long ss; -} PACKED execution_context_t; - -typedef struct shared_info_st -{ - struct { - u8 evtchn_upcall_pending; - u8 evtchn_upcall_mask; - u8 pad0, pad1; - } PACKED vcpu_data[MAX_VIRT_CPUS]; /* 0 */ - u32 evtchn_pending[32]; /* 4 */ - u32 evtchn_pending_sel; /* 132 */ - u32 evtchn_mask[32]; /* 136 */ - u64 cpu_freq; /* 264: CPU frequency (Hz). */ - u32 time_version1; /* 272 */ - u32 time_version2; /* 276 */ - tsc_timestamp_t tsc_timestamp; /* TSC at last update of time vals. */ - u64 system_time; /* Time, in nanosecs, since boot. */ - u32 wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */ - u32 wc_usec; /* Usecs 00:00:00 UTC, Jan 1, 1970. */ - u64 domain_time; /* Domain virtual time, in nanosecs. */ - u64 wall_timeout; /* 312 */ - u64 domain_timeout; /* 320 */ - execution_context_t execution_context; /* 328 */ - arch_shared_info_t arch; -} PACKED shared_info_t; - -/* End of stuff which belongs in a Xen header */ - struct list_head { struct list_head *next, **pprev; -- 2.30.2